<?php

$images_url = base_url('images');
$main_url = base_url('main');
$usaha_url = base_url('usaha');

$mapdir = "
	<a href='$main_url'>Home</a>
	&gt; 
	<b>Usaha</b>
";


$awal = $this->uri->segment(3, 0);
$order = $this->input->get('order');
$kat = $this->input->get('kat');
$daftarkategori = "";
$datausaha = "";

$kategori = $this->mainmodel->get_daftar_kategori();
if($kategori !== FALSE)
{
	$jumkat = $kategori->num_rows();
	$tengah = ceil($jumkat/2);
	$kathit = 1;
	$katkanan = "";
	$katkiri = "";
	
	foreach($kategori->result() AS $cat)
	{
		
		if($kathit <= $tengah)
		{
			$katkanan .= "<a href='$main_url/usaha.html?order=cat&amp;kat=$cat->idkategori'>$cat->kategori</a> <br />";
		}
		else
		{
			$katkiri .= "<a href='$main_url/usaha.html?order=cat&amp;kat=$cat->idkategori'>$cat->kategori</a> <br />";
		}
		$kathit++;
	}
	
	$daftarkategori = "
		<div id='kategori'>
			<div class='left'>$katkanan</div>
			<div class='right'>$katkiri</div>
		</div>
	";
}

$config['base_url'] = base_url('main/partner');
$config['total_rows'] = $this->mainmodel->hitung_data('idperusahaan','dn_company');
$config['per_page'] = 10; 
$config['first_url'] = base_url('main/partner.html?order='.$order); 
$config['suffix'] = '/list.html?order='.$order;

switch ($order)
{
	case "asc":
		$usaha = $this->mainmodel->get_daftar_perusahaan($awal, 'asc');
	;
	break;
	
	case "abja":
		$usaha = $this->mainmodel->get_daftar_perusahaan_abj($awal, 'asc');
	;
	break;
	
	case "abjz":
		$usaha = $this->mainmodel->get_daftar_perusahaan_abj($awal, 'desc');
	;
	break;
	
	case "cat":
		$usaha = $this->mainmodel->get_daftar_perusahaan_cat($awal, $kat);
		
		$config['base_url'] = base_url('main/partner');
		$config['total_rows'] = $this->mainmodel->hitung_perusahaan_per_kategori($kat);
		$config['per_page'] = 10; 
		$config['first_url'] = base_url('main/partner.html?order='.$order); 
		$config['suffix'] = '/list.html?order='.$order.'&cat='.$kat;
	;
	break;
	
	default:
		$usaha = $this->mainmodel->get_daftar_perusahaan($awal, 'desc');
	;
	break;
}

try{
	$hit = $awal+1;
}catch (Exception $e){
	$hit = 1;
}

if($usaha !== FALSE)
{
	foreach($usaha AS $udata)
	{
		$idc = $udata->idperusahaan;
		$nama = $udata->nama;
		$title = url_title($udata->nama, '-', TRUE);
		
		if($hit % 2 == 0)
		{
			$warna = "bgputih";
		}
		else
		{
			$warna = "bgbiru";
		}
		
		$datausaha .= "
		<tr class='$warna'>
			<td class='left'>$hit. <a href='$usaha_url/$idc/$title/company.html'>$nama</a></td>
			<td class='right'><a href='$usaha_url/$idc/$title/company.html'>Detail</a><br /> 
			<a href='$usaha_url/$idc/$title/produk.html'>Produk $nama</a><br /> 
			<a href='$usaha_url/$idc/$title/loker.html'>Info Lowongan</a>
			</td>
		</tr>";
		$hit++;
	}
}
else
{
	$datausaha .= "
		<tr>
			<td class='left'>&nbsp;</td>
			<td class='right'>Belum Ada Data</td>
		</tr>";
}



$this->pagination->initialize($config); 		
$halaman = $this->pagination->create_links();

$isipage = "
	<div id='content2'>
			<h3>Daftar Perusahaan</h3>
				
				
				<div class='isicontent2'>
				  <p>
					 Urutan berdasarkan : 
					 <a href='$main_url/usaha.html?order=desc'>Terbaru</a> | 
					 <a href='$main_url/usaha.html?order=asc'>Terlama</a> | 
					 <a href='$main_url/usaha.html?order=abja'>Abjad A-Z</a> | 
					 <a href='$main_url/usaha.html?order=abjz'>Abjad Z-A</a>  
				  </p>
				</div>
				
				
				<div class='isicontent2'>
				  <p>
					 Usaha berdasarkan Kategori : 
				  </p>
				  
				  $daftarkategori
				  
				  <br />
				  <div class='blank'></div>
				</div>
				
				
				<div class='isicontent2'>
				
					<table>
						<tbody>
						
							$datausaha
							
							<tr><td class='left'>&nbsp;</td><td class='right'>$halaman</td></tr>
						</tbody>
					</table>
				  
				  
				</div>
			</div>
";

$data['map_dir'] = $mapdir;
$data['isi_page'] = $isipage;
$data['site_title'] = 'Usaha - Dadan Network';
$data['site_description'] = 'Dadan Network adalah situs berbagi informasi tentang jaringan profesional antar enterpreneur indonesia';
$data['site_keywords'] = 'dadan, network, profesional, enterpreneur, produk, usaha';
$data['base_url'] = base_url();
$data['tahun_sekarang'] = date("Y");
$data['other_head'] = '';

$this->parser->parse('template/home', $data);

/* End of file perusahaan.php */
/* Location: ./application/views/main/perusahaan.php */
